<?php
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('exercise.stylesheet');
$canDo = ExercisesHelper::getActions();
$user = JFactory::getUser();
$userId = $user->get('id');

?>
<script type="text/javascript">
    Joomla.submitbutton = function(task)
    {
        if (task == 'answer.cancel' || document.formvalidator.isValid(document.id('answer-form'))) {
            Joomla.submitform(task, document.getElementById('answer-form'));
        }
    }
</script>

<form action="<?php echo JRoute::_('index.php?option=com_exercises&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="answer-form" class="form-validate">

    <div class="width-60 fltlft">
        <fieldset class="adminform">
            <legend><?php echo empty($this->item->id) ? JText::_('COM_EXERCISES_NEW_ANSWER') : JText::sprintf('COM_EXERCISES_EDIT_ANSWER', $this->item->id); ?></legend>
            <ul class="adminformlist">

                <li><?php echo $this->form->getLabel('user_id'); ?>
                    <?php echo $this->form->getInput('user_id'); ?></li>                                
                <?php if(($this->item->user_id)!='' && ($this->item->user_id)!=0){
                    $userdo = JFactory::getUser($this->item->user_id);
                    ?>
                <li><label><?php echo JText::_('COM_EXERCISES_USER_DO')?></label><?php echo $userdo->vanbaivip?></li>
                        <?php
                    }?>
                 
                <li><?php echo $this->form->getLabel('ques_id'); ?>
                    <?php echo $this->form->getInput('ques_id'); ?></li>
                
                <li><?php echo $this->form->getLabel('answer'); ?>
                    <?php echo $this->form->getInput('answer'); ?></li>
                <?php if ($canDo->get('core.edit.state')) : ?>
                    <li><?php echo $this->form->getLabel('state'); ?>
                        <?php echo $this->form->getInput('state'); ?></li>
                <?php endif; ?>

                <li><?php echo $this->form->getLabel('id'); ?>
                    <?php echo $this->form->getInput('id'); ?></li>
            </ul>

        </fieldset>
    </div>

    <div class="width-40 fltrt">
        <?php echo JHtml::_('sliders.start', 'exercise-answer-sliders-' . $this->item->id, array('useCookie' => 1)); ?>

        <?php echo JHtml::_('sliders.panel', JText::_('COM_EXERCISES_GROUP_LABEL_PUBLISHING_ANSWER_DETAILS'), 'publishing-details'); ?>
        <fieldset class="panelform">
            <ul class="adminformlist">
                <?php foreach ($this->form->getFieldset('publish') as $field): ?>
                    <li>
                        <?php if (!$field->hidden): ?>
                            <?php echo $field->label; ?>
                        <?php endif; ?>
                        <?php echo $field->input; ?>
                    </li>
                <?php endforeach; ?>
            </ul>
        </fieldset>


        <input type="hidden" name="modifiedby" value="<?php echo $userId; ?>" />
        <input type="hidden" name="modified" value="<?php echo date("Y-m-d H:i:s"); ?>" />        
        <input type="hidden" name="task" value="" />
        <?php echo JHtml::_('form.token'); ?>
    </div>

    <div class="clr"></div>
</form>
